//
// Created by xili on 2024/8/27 20:13.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    vector<int> resultsArray(vector<int> &nums, int k) {
        int n = nums.size();
        vector<int> ans(n - k + 1, -1);
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (i == 0 || nums[i] == nums[i - 1] + 1) {
                sum++;
            } else {
                sum = 1;
            }
            if (sum >= k) {
                ans[i - k + 1] = nums[i];
            }
        }
        return ans;
    }
};